package com.mf.controller;

import com.mf.entity.vo.WorkInfoVo;
import com.mf.service.IWorkInfoService;
import io.github.heollhai.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author mf
 * @since 2024-09-01
 */
@RestController
@RequestMapping("personnel/workInfo/v1")
@Tag(name = "工作信息")
public class WorkInfoController {
    @Resource
    private IWorkInfoService workInfoService;
    
    @Operation(summary = "新增|编辑")
    @PostMapping("save")
    public Result<Integer> save(@Valid @RequestBody() WorkInfoVo workInfoVo) {
        return Result.success(workInfoService.insert(workInfoVo));
    }

    @Operation(summary = "删除")
    @PostMapping("delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Integer id) {
        return Result.success(workInfoService.removeById(id));
    }

    @Operation(summary = "查询")
    @GetMapping("list")
    public Result<List<WorkInfoVo>> list(@RequestParam("rosterId") Integer rosterId) {
        return Result.success(workInfoService.listByRosterId(rosterId));
    }
}
